<% 
 # Testing pagination
 # <pre>
 #   <%= @pagination.to_yaml %>
 # </pre>
%>

<% if @pagination %>
  <div class="pagination">
  <% if @pagination[:previous] then %>
    <a href="/<%= @pagination[:slug] %>-page-<%= @pagination[:page]-1 %>/" 
      rel="previous" class="next_page">← Previous</a>
  <% else %>  
    <span class="disabled previous_page">← Previous</span>
  <% end %>

    <% [*1..@pagination[:total_page]].each do |p| %>
      <% if p == @pagination[:page] then %>
        <em class="current"><%= p %></em>
      <% else %>
        <a href="/<%= @pagination[:slug] %>-page-<%= p %>/"
         <% if p == (@pagination[:page]-1) then %>
         rel="previous"
         <% elsif p == (@pagination[:page]+1) %>
          rel="next"
         <% end %>
         ><%= p %></a> 
      <% end %>
    <% end %>

<% #Not handled   <span class="gap">…</span> %>

  <% if @pagination[:next] then %>
    <a href="/<%= @pagination[:slug] %>-page-<%= @pagination[:page]+1 %>/" 
      rel="next" class="next_page">Next →</a>
  <% else %>
    <span class="disabled next_page">Next →</span>
  <% end %>
  </div>
<% end %>

